package ocean.service;

import java.awt.Point;

import ocean.data.DataHolder;
import ocean.service.I.MoveGenerator;

public class FloraAndFaunaLocInit extends MoveGenerator
{

    protected static int generate()
    {
	return DataHolder.getObjSize() * DataHolder.getGenStepMin()
		+ (int) (Math.random() * ((DataHolder.getGenStepMax() - DataHolder.getGenStepMin()) + 1));
    }

    protected static int gen(int to)
    {
	int res = 0;
	for (int i = 0; i < to; i += DataHolder.getObjSize())
	{
	    res += generate();
	}

	return res;
    }

    public static Point getFreePosition()
    {
	Point res = new Point();
	res.x = gen(DataHolder.getOceanWidth());
	res.y = gen(DataHolder.getOceanHeight());

	while (!checkLocationForStopObjects(res))
	{
	    res.setLocation(gen(DataHolder.getOceanWidth()), gen(DataHolder.getOceanHeight()));
	}

	return res;

    }

}
